//
//  Bootstrapper.swift
//  Center
//
//  Created by 蒋晨成 on 2021/12/23.
//

import Center_AppInfo
import Center_OSS
import Center_RPC
import Foundation
import Monitor
import Standard

public enum Bootstrapper: Bootable {
    @DelayInit
    public private(set) static var environment: Standard.Environmental

    public static func register(environment: Standard.Environmental) -> Self.Type {
        self.environment = environment
        return self
    }

    public static func bootstrap() -> Self.Type {
        injectContexts()
        submoduleBootstrap()

        return self
    }
}

private extension Bootstrapper {
    static func injectContexts() {
        RPCCenter.register(azirContext: AzirRPCServiceContext())
        TencentCOSCenter.register(context: TencentCOSContext())
    }

    static func submoduleBootstrap() {
        #if DEBUG
            PerformanceMonitor.startMonitoring()
        #endif
    }
}
